package es

import (
	"github.com/olivere/elastic/v7"
)

//  -------------------------------------------- Pipeline Metrics -------------------------------------------
// 平均值桶聚合
func (m *Model) AvgBucketAggregation(name, field, policy string) *Model {
	return m.SubAggregation(name, elastic.NewAvgBucketAggregation().BucketsPath(field).GapPolicy(policy))
}

// 导数聚合
func (m *Model) DerivativeAggregation(name, field, policy string) *Model {
	return m.SubAggregation(name, elastic.NewDerivativeAggregation().BucketsPath(field).GapPolicy(policy))
}

// 求和值桶聚合
func (m *Model) CumulativeSumAggregation(name, field string) *Model {
	return m.SubAggregation(name, elastic.NewCumulativeSumAggregation().BucketsPath(field))
}

// 扩展信息桶聚合
func (m *Model) ExtendedStatsBucketAggregation(name, field, policy string) *Model {
	return m.SubAggregation(name, elastic.NewExtendedStatsBucketAggregation().BucketsPath(field).GapPolicy(policy))
}

// 最大值桶聚合
func (m *Model) MaxBucketAggregation(name, field, policy string) *Model {
	return m.SubAggregation(name, elastic.NewMaxBucketAggregation().BucketsPath(field).GapPolicy(policy))
}

// 最小值桶聚合
func (m *Model) MinBucketAggregation(name, field, policy string) *Model {
	return m.SubAggregation(name, elastic.NewMinBucketAggregation().BucketsPath(field).GapPolicy(policy))
}

// 统计桶聚合
func (m *Model) StatsBucketAggregation(name, field, policy string) *Model {
	return m.SubAggregation(name, elastic.NewStatsBucketAggregation().BucketsPath(field).GapPolicy(policy))
}

// 累积汇总聚合
func (m *Model) SumBucketAggregation(name, field, policy string) *Model {
	return m.SubAggregation(name, elastic.NewSumBucketAggregation().BucketsPath(field).GapPolicy(policy))
}


